<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
    <meta charset="UTF-8">
    <title>我的订单</title>
    <link href="__PUBLIC__/layui/css/layui.css" rel="stylesheet" />
    <link rel="stylesheet" href="__PUBLIC__/css/global.css" media="all">
  <link href="__PUBLIC__/Font-Awesome/css/font-awesome.css" rel="stylesheet" />
</head>
<style>
    .site-table{width: 100%;}
</style>

<body>
<div class="admin-main">
   <!-- <blockquote class="layui-elem-quote">
        <form  class="layui-form" action="">
            <div class="custom-form-item">
                <label class="layui-form-label">团队订单：</label>
                <div class="layui-input-inline">
                    <select name="orderstatus">
                        <option value="">团队订单状态 </option>&lt;!&ndash;1:正常 2：结束 3：删除 4：抢购中&ndash;&gt;
                        <option value="1" <if condition="$_GET['teamstatus'] eq 1">selected</if>>排队抢购中</option>
                        <option value="2" <if condition="$_GET['teamstatus'] eq 2">selected</if>>结束</option>
                        <option value="3" <if condition="$_GET['teamstatus'] eq 3">selected</if>>删除</option>
                        <option value="4" <if condition="$_GET['teamstatus'] eq 4">selected</if>>抢购中</option>
                    </select>
                </div>
            </div>
            <div class="custom-form-item">
                <label class="layui-form-label">团队名称：</label>
                <div class="layui-input-inline">
                    <input type="text" name="teamname" maxlength="20" placeholder="团队名称匹配" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="custom-form-item">
                <button class="layui-btn search" lay-submit lay-filter="search">搜索</button>
            </div>
            <div class="layui-clear"></div>
        </form>
    </blockquote>-->

    <fieldset class="layui-elem-field">
        <legend>任务列表</legend>
        <div class="layui-field-box">
            <table class=" site-table">
                <thead>
                <tr>
                    <th>订单号</th>
                    <th>团队名称</th>
                    <th>邮箱</th>
                    <th>订单站点</th>
                    <th style="max-width: 120px;">商品名称</th>
                    <th>商品规格</th>
                    <th>需支付金额</th>
                    <th>订单状态</th>
                </tr>
                </thead>
                <tbody id="listcontent" class="layui-form">
                </tbody>
            </table>
        </div>
    </fieldset>
    <div class="admin-table-page">
        <div id="page" class="page">
        </div>
    </div>
</div>
<script id="demo" type="text/html">
    <tr>
        <td>{{d.thirdorderid }}</td>
        <td>{{d.t_name}}</td>
        <td>{{d.u_eamil }}</td>
        <td>{{d.site_name}}</td>
        <td style="max-width: 120px;text-overflow: ellipsis; overflow: hidden;">{{d.order_name}}</td>
        <td> {{# if(d.remark && d.remark !== ''){ }}{{d.remark.sytle}}　{{d.remark.size}}　{{d.remark.color}}{{# }}}</td>
        <td>{{d.order_price}}</td>
        <td>
            {{# if(d.order_type == 2){ }} <span>已付款</span> {{# }else if(d.order_type == 1){ }} <span>待付款</span>{{# }}}
        </td>

       <!-- <td>
            {{# if(d.order_type == 1){ }}
            <a  data="{{d.order_id}}" class="layui-btn layui-btn-normal layui-btn-mini gopay"><i class="layui-icon"></i>去付款</a>
            {{# }else if(d.order_type == 2){}}
            <a  data="{{d.order_id}}" class="layui-btn layui-btn-mini getemress">获取快递</a>
            {{# }}}
            <a  data="{{d.order_id}}" class="layui-btn layui-btn-danger layui-btn-mini del"><i class="layui-icon">&#xe640;</i>删除</a>
        </td>-->
    </tr>
</script>
<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>

<script>
    var form,layer,$,laydate;
    layui.config({
        base: '__PUBLIC__/layui/modules/'
    });
    layui.use(['layer', 'form','laypage','laytpl','laydate'], function () {
        var laypage = layui.laypage,laytpl = layui.laytpl;
        laydate = layui.laydate;
        form = layui.form();
        $ = layui.jquery
        layer=layui.layer;
        var pagelistdate;
        var curr;
        form.render();
        laypage({
            cont: 'page',
            pages: {$page} //总页数
            ,skip: true
            ,
            groups: 5 //连续显示分页数
            ,

            jump: function(obj, first) {
                curr = obj.curr;
                listcontent.innerHTML='';
                $.ajax({
                    type: "GET",
                    url: "",
                    data: { p:curr},
                    async: false,
                    success: function(date){
                        if(date['code']==101) {
                            pagelistdate =date .data;
                            layui.each(date.data, function (k, v) {
                                var getTpl = demo.innerHTML;
                                laytpl(getTpl).render(v, function (html) {
                                    listcontent.innerHTML += html;
                                });
                            });
                        }
                    }
                });

                caozuo();

            }
        });

      /*  $('.add').click(function(){
            var url = "{:U('Team/createTeamTask')}";
            $.get(url,function(data){
                if(data.code == '4001'){
                    layer.msg(data.msg,{icon: 5});
                    return;
                }
                layer.open({
                    title:'创建团队任务',
                    type: 1,
                    skin: 'layui-layer-rim',
                    area: ['800px','500px'],
                    content: data
                });
            });
        });*/

        function caozuo(){
            $('.gopay').click(function () {
                var url = "{:U('MyOrder/goPay')}";
                var id = $(this).attr('data');
                _this=$(this);
                    $.post(url, {id: id}, function (data) {
                        if (data.code == '4001') {
                            layer.msg(data.msg, {icon: 5});
                            return;
                        } else {
                            layer.confirm('', {
                                title:'支付',
                                skin: 'layer-ext-moon',
                                content: data.data,
                                btn: ['已经扫码','未扫码']
                            }, function() {
                                $.post("{:U('MyOrder/confirmGoPay')}", {id: id}, function (data) {
                                    if(data.code==101) {
                                        //_this.remove();
                                        _this.html('<a  data="'+id+'" class="layui-btn layui-btn-mini getemress">获取快递</a>');
                                        layer.closeAll()
                                    }
                                    caozuo();
                                    layer.msg(data.msg, {icon: 6});
                                    return;
                                });

                            });
                        }

                });
            });
            $('.getemress').click(function () {
                var id = $(this).attr('data');
                var bb =layer.load(1, {shade: [0.8, '#393D49'], time: 100000})
                var url = "{:U('MyOrder/getExpress')}";
                $.post(url,{keyid:id},function(data){
                    if(data.code == '4001'){
                        layer.msg(data.msg,{icon: 5});
                        return;
                    }else {
                        layer.open({
                            title: '快递信息',
                            type: 1,
                            skin: 'layui-layer-rim',
                            area: ['400px', '200px'],
                            content: data.data,
                            success: function(layero, index){
                                layer.close(bb);
                            }
                        });
                    }
                });
            });

            $('.del').click(function () {
                var id = $(this).attr('data');
                var url = "{:U('MyOrder/delorder')}";
                layer.confirm('确定删除吗', {
                    icon: 3,
                    skin: 'layer-ext-moon',
                    btn: ['确认','取消']
                }, function(){
                    $.post(url,{keyid:id},function(data){
                        if(data.code=='4001'){
                            layer.msg(data.msg,{icon: 5});
                        }else{
                            layer.msg(data.msg, {
                                icon: 6,
                                time: 2000
                            }, function(){
                                window.location.reload();
                            });
                        }
                    });
                });
            });
        }
    });
</script>
</body>

</html>